package field_REGEX_Definitions.DebixFields;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import field_REGEX_Definitions.Field;
import fields.*;


public class Zip_Code implements Field{
	private Pattern zipCode = Pattern.compile("[\\n\\s]*((zip\\s*code)|(postal\\s*code))[:\\n\\s]*((\\d{5}-\\d{4})|(\\d{5}))",Pattern.CASE_INSENSITIVE);
	private String field;
	private String type = "debix";
	
	public boolean matches(String input) {
		Matcher matcher = zipCode.matcher(input);
		boolean result = matcher.find();
		if (result) {
			field = "Zip Code";
		}
		return result;
	}
	
	public String getFieldName(){
		return field;
	}

	public ZipCode execute() {
		return new ZipCode(field,"Debix");
	}

	@Override
	public String getFieldType() {
		return type;
	}
}
